

package body sdl_events_h is

   -- Return the type of the event
   function Type_Of (Event : Sdl_Event) return Sdl_Eventtype is
   begin
      return Event.C_Type;
   end;


   -- Waits indefinitely for the next available event,
   -- returning the event or raising excetption if there was an error
   function Wait_Event return Sdl_Event is

   --   Waits indefinitely for the next available event, returning 1, or 0 if there
   --   was an error while waiting for events.  If 'event' is not NULL, the next
   --   event is removed from the queue and stored in that area.
      function Sdl_Waitevent (Event : access Sdl_Event) return Int;  -- SDL_events.h:277:59
      pragma Import (C, Sdl_Waitevent, "SDL_WaitEvent");

      Event : aliased Sdl_Event;
      Error_While_Waiting_Event : exception;
   begin
      if Sdl_Waitevent (Event'Access) = 1 then
         return Event;
      else
         raise Error_While_Waiting_Event;
      end if;
   end Wait_Event;

   function Sdl_Pollevent (Event : access Sdl_Event) return Boolean is
   --   Polls for currently pending events, and returns 1 if there are any pending
   --   events, or 0 if there are none available.  If 'event' is not NULL, the next
   --   event is removed from the queue and stored in that area.
      function Sdl_Pollevent (Event : access Sdl_Event) return Int;  -- SDL_events.h:271:59
      pragma Import (C, Sdl_Pollevent, "SDL_PollEvent");
   begin
      return (Sdl_Pollevent (Event) = 1);
   end Sdl_Pollevent;

end sdl_events_h;
